<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../common/base_body_header.jsp" %>
<%@include file="../common/navbar.jsp" %>
<%@include file="../common/page_content_pre.jsp" %>

<link rel="stylesheet" href="${GLOBAL.staticJsPath}/assets/qiniu/fileupload.css"/>

<div class="page-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="widget-box">
                <div class="widget-header">
                    <h4>合同详情</h4>
                </div>

                <div class="widget-body">
                    <div class="widget-main no-padding">
                        <form:form class="form-horizontal" modelAttribute="contract" enctype="multipart/form-data"
                                   action="${GLOBAL.basePath}/contract/save" method="post" id="contractForm">
                            <form:input path="contractId" type = "hidden"/>
                            <input id="cellId" type="hidden" value="${contract.cellId}">

                            <c:if test="${not empty contract.contractId}">
                                <fieldset>
                                    <div class="form-group">
                                        <span class="col-sm-3 control-label">合同编号：</span>
                                        <label class="control-label">${contract.contractId}</label>
                                    </div>
                                </fieldset>
                            </c:if>

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">客户姓名：</label>
                                    <div class="col-sm-5">
                                        <label class="control-label">${contract.customerName}</label>
                                    </div>
                                </div>
                            </fieldset>

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2"></label>
                                    <table>
                                        <tr>
                                            <td width="85px">小区名称：</td>
                                            <td class="col-sm-3">
                                                ${contract.nbhName}
                                            </td>
                                            <td style="width: 60px;" align="right">楼号：</td>
                                            <td>${contract.cellId}</td>
                                            <td style="width: 60px;" align="right">单元：</td>
                                            <td>${contract.unitNo}</td>
                                            <td style="width: 60px;" align="right">室号：</td>
                                            <td>${contract.roomNo}</td>
                                        </tr>
                                    </table>
                                </div>
                            </fieldset>

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">成交价：</label>

                                    <div class="col-sm-5">
                                        <label class="control-label">${contract.transactionPrice}</label>
                                    </div>
                                </div>
                            </fieldset>

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">成交时间：</label>

                                    <div class="col-sm-4">
                                        <label class="control-label"><fmt:formatDate value="${contract.transactionDate}" pattern="yyyy-MM-dd HH:mm:ss" /></label>
                                    </div>
                                </div>
                            </fieldset>

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">经纪人：</label>

                                    <div class="col-sm-5">
                                        <label class="control-label">${contract.userName}</label>
                                    </div>
                                </div>
                            </fieldset>

                            <hr/>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">合同文档：</label>

                                    <div class="col-sm-6">
                                        <div id="photos" class="row" style="width:750px">
                                            <div id = "contractLocationDiv" class="col-xs-4">
                                                <c:if test="${not empty contract.contractLocation}">
                                                    <label><a href="${contract.contractLocation}">${contract.contractLocation}</a></label>
                                                </c:if>
                                            </div>
                                            <input id = "contractLocation" name ="contractLocation" type="hidden" value="${contract.contractLocation}">
                                        </div>
                                    </div>
                                </div>
                            </fieldset>

                            <hr/>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">实景图：</label>

                                    <div class="col-sm-6">
                                        <div id="photos1" class="row" style="width:750px">
                                            <c:if test="${photoList!= null || fn:length(photoList) > 0}">
                                                <c:forEach items="${photoList}" var="item" varStatus="plist">
                                                    <div id="${item.photoSource}-id" class="col-xs-4"><img
                                                            id="${item.photoSource}"
                                                            src="${storeUrl}${item.photoSource}?imageView2/0/w/160/h/160">

                                                        <div class="q-label"><input value="${item.photoDesc}"></div>
                                                    </div>
                                                </c:forEach>
                                            </c:if>
                                        </div>
                                        <span id="uploadInfo1" style="color: red"></span>
                                    </div>
                                </div>
                            </fieldset>

                            <div class="form-actions center">
                                <button type="button" class="btn btn-sm btn-grey" id="go_back_btn">
                                    返回
                                    <i class="icon-reply icon-on-right bigger-110"></i>
                                </button>
                            </div>
                        </form:form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<%@include file="../common/page_content_suf.jsp" %>
<%@include file="../common/script.jsp" %>

<script type="text/javascript">
    var qiniuDomain = '${GLOBAL.basePath}';
    var qiniuPath = '${GLOBAL.qiniuPath}';

    $(document).ready(function () {
        $(".js-example-basic-single").select2(); //

        $("#go_back_btn").on("click", function () {
            goBack();
        });
    });

    function goBack() {
        document.location.href = "${GLOBAL.basePath}/contract/list";
    }
</script>
